import joblib
import numpy as np
from sklearn.preprocessing import StandardScaler
from Tools import metrics_result
from Tools import readbunchobj
from joblib import dump

# 导入训练集
trainpath = "../train_word_bag/tf_idf_space.dat"
train_set = readbunchobj(trainpath)

# 导入测试集
testpath = "../test_word_bag/test_tf_idf_space.dat"
test_set = readbunchobj(testpath)

vectorizer = joblib.load('../vectorizer.joblib')

def clf_result(model_clf):

    # 预测分类结果
    model_predicted = model_clf.predict(test_set.tdm)
    model_total = len(model_predicted)

    # 性能评估
    metrics_result(test_set.label, model_predicted, model_total)

if __name__ == '__main__':
    print('\nBayes模型性能：')
    clf = joblib.load('Bayes_model.joblib')
    clf_result(clf)

    print('\n逻辑回归模型性能：')
    clf = joblib.load('LogisticRegression_model.joblib')
    clf_result(clf)

    print('\n随机森林模型性能：')
    clf = joblib.load('RF_model.joblib')
    clf_result(clf)

    print('\nEL模型性能：')
    clf = joblib.load('EL_model_cv.joblib')
    clf_result(clf)




